//
//  warningDetailViewController.m
//  WHB_logist
//
//  Created by 徐国庆 on 15/12/2.
//  Copyright (c) 2015年 turing. All rights reserved.
//

#import "warningDetailViewController.h"
#import "warningDetailCell.h"

@interface warningDetailViewController ()<UITableViewDataSource, UITableViewDelegate>

@property(nonatomic, strong)UITableView *tableView;
@property(nonatomic, strong)NSString *titlel;

@end

@implementation warningDetailViewController

- (instancetype)initWithTitle:(NSString *)title{
    self = [super init];
    if (self) {
        _titlel = title;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.navtitle.text = self.titlel;
    [self initWithView];
}

#pragma mark UITableViewDelegate

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UILabel *timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kUIScreenWidth, 50)];
    timeLabel.text = @"2015-08-09    17:20";
    timeLabel.font = [UIFont systemFontOfSize:15];
    timeLabel.textColor = [UIColor HexStrWithColor:@"3C3C3C"];
    timeLabel.backgroundColor = [UIColor HexStrWithColor:@"F0F0F0"];
    timeLabel.textAlignment = 1;
    timeLabel.layer.borderWidth = 0.5;
    timeLabel.layer.borderColor = [UIColor blackColor].CGColor;
    
    return timeLabel;
}


- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 10;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    NSString * indentifer = @"warningDetail";
    
    warningDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:indentifer];
    if (cell == nil) {
        cell = [[warningDetailCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indentifer];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.selectedBackgroundView.backgroundColor = [UIColor clearColor];
    cell.contentView.backgroundColor = [UIColor HexStrWithColor:@"eeeeee"];
    
    cell.timeLabel.backgroundColor = [UIColor HexStrWithColor:@"cccccc"];
    cell.timeLabel.textColor = [UIColor HexStrWithColor:@"ffffff"];
    cell.timeLabel.layer.masksToBounds = YES;
    cell.timeLabel.layer.cornerRadius = 5;
    cell.timeLabel.text = @"2014-11-16 20:30:25";
    cell.timeLabel.textAlignment = 1;
    cell.timeLabel.font = [UIFont systemFontOfSize:14];
    
    cell.contentLabel.backgroundColor = [UIColor whiteColor];
    cell.contentLabel.textColor = [UIColor HexStrWithColor:@"000000"];
    cell.contentLabel.layer.masksToBounds = YES;
    cell.contentLabel.layer.cornerRadius = 5;
    
    cell.bottomView.layer.borderColor = [UIColor HexStrWithColor:@"d5d5d5"].CGColor;
    
    NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"您已连续驾驶车辆粤B12345超过4小时，请注意休息！"];
    [str addAttribute:NSForegroundColorAttributeName value:[UIColor HexStrWithColor:@"ff6600"] range:NSMakeRange(17,3)];
    cell.contentLabel.attributedText = str;
    cell.contentLabel.numberOfLines = 0;
    cell.contentLabel.font = [UIFont systemFontOfSize:17];
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 100;
}

- (void)initWithView{
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kUIScreenWidth, kUIScreenHeight - kNavHeight) style:UITableViewStylePlain];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:self.tableView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
